#include "searchwindow.h"
#include "deletewindow.h"
#include "changewindow.h"
#include "mainwindow.h"
#include "addwindow.h"
#include <QGridLayout>
#include <QAction>

MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
{
    this->setFixedSize(300,320);
    add     = new QPushButton("增");add->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    remove  = new QPushButton("删");remove->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    change  = new QPushButton("改");change->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    check   = new QPushButton("查");check->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    QGridLayout* g=new QGridLayout();
    g->addWidget(add,0,0,1,1);g->addWidget(remove,0,1,1,1);
    g->addWidget(change,1,0,1,1);g->addWidget(check,1,1,1,1);
    this->setLayout(g);
    connect(check,&QPushButton::clicked,this,
            [=]()
    {
        SearchWindow* sw=new SearchWindow(this);
        sw->setAttribute(Qt::WA_DeleteOnClose);
        sw->setWindowFlag(Qt::Window,true);
        sw->show();
    });
    connect(remove,&QPushButton::clicked,this,
            [=]()
    {
        DeleteWindow* dw=new DeleteWindow(this);
        dw->setAttribute(Qt::WA_DeleteOnClose);
        dw->setWindowFlag(Qt::Window,true);
        dw->show();
    });
    connect(add,&QPushButton::clicked,this,
            [=]()
    {
        AddWindow* dw=new AddWindow(this);
        dw->setAttribute(Qt::WA_DeleteOnClose);
        dw->setWindowFlag(Qt::Window,true);
        dw->show();
    });
    connect(change,&QPushButton::clicked,this,
            [=]()
    {
        ChangeWindow* dw=new ChangeWindow(this);
        dw->setAttribute(Qt::WA_DeleteOnClose);
        dw->setWindowFlag(Qt::Window,true);
        dw->show();
    });
}

MainWindow::~MainWindow()
{
}

